﻿using System;
using System.Globalization;
using log4net;

namespace Loki.Utils
{
    /// <summary>
    /// Logger proxy class.
    /// </summary>
    public class LoggerProxy : ILog
    {
        private log4net.ILog _Logger;

        /// <summary>
        /// Initializes a new instance of the <see cref="LoggerProxy"/> class.
        /// </summary>
        /// <param name="P_LoggerName">The logger name.</param>
        public LoggerProxy(string P_LoggerName)
        {
            _Logger = LogManager.GetLogger(P_LoggerName);
        }

        /// <summary>
        /// Logs the specified info.
        /// </summary>
        /// <param name="P_Message">The message.</param>
        public void Info(string P_Message)
        {
            _Logger.Info(P_Message);
        }

        /// <summary>
        /// Logs the specified info.
        /// </summary>
        /// <param name="P_Message">The message.</param>
        /// <param name="P_Exception">The exception.</param>
        public void Info(string P_Message, Exception P_Exception)
        {
            _Logger.Info(P_Message, P_Exception);
        }

        /// <summary>
        /// Logs the specified info.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        /// <param name="P_Args">The Args.</param>
        public void InfoFormat(string P_Message, params object[] P_Args)
        {
            _Logger.InfoFormat(CultureInfo.InvariantCulture, P_Message, P_Args);
        }

        public void InfoFormat(string P_Message, Exception P_Exception, params object[] P_Args)
        {
            _Logger.Info(string.Format(CultureInfo.InvariantCulture, P_Message, P_Args), P_Exception);
        }

        /// <summary>
        /// Logs the specified debug info.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        public void Debug(string P_Message)
        {
            _Logger.Debug(P_Message);
        }

        /// <summary>
        /// Logs the specified debug info.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        /// <param name="P_Exception">The Exception.</param>
        public void Debug(string P_Message, Exception P_Exception)
        {
            _Logger.Debug(P_Message, P_Exception);
        }

        /// <summary>
        /// Logs the specified debug info.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        /// <param name="P_Args">The Args.</param>
        public void DebugFormat(string P_Message, params object[] P_Args)
        {
            _Logger.DebugFormat(CultureInfo.InvariantCulture, P_Message, P_Args);
        }

        public void DebugFormat(string P_Message, Exception P_Exception, params object[] P_Args)
        {
            _Logger.Debug(string.Format(CultureInfo.InvariantCulture, P_Message, P_Args), P_Exception);
        }

        /// <summary>
        /// Logs the specified warning.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        public void Warn(string P_Message)
        {
            _Logger.Warn(P_Message);
        }

        /// <summary>
        /// Logs the specified warning.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        /// <param name="P_Exception">The Exception.</param>
        public void Warn(string P_Message, Exception P_Exception)
        {
            _Logger.Warn(P_Message, P_Exception);
        }

        /// <summary>
        /// Logs the specified warning.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        /// <param name="P_Args">The Args.</param>
        public void WarnFormat(string P_Message, params object[] P_Args)
        {
            _Logger.WarnFormat(CultureInfo.InvariantCulture, P_Message, P_Args);
        }

        public void WarnFormat(string P_Message, Exception P_Exception, params object[] P_Args)
        {
            _Logger.Warn(string.Format(CultureInfo.InvariantCulture, P_Message, P_Args), P_Exception);
        }

        /// <summary>
        /// Logs the specified error.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        public void Error(string P_Message)
        {
            _Logger.Error(P_Message);
        }

        /// <summary>
        /// Logs the specified error.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        /// <param name="P_Exception">The Exception.</param>
        public void Error(string P_Message, Exception P_Exception)
        {
            _Logger.Error(P_Message, P_Exception);
        }

        /// <summary>
        /// Logs the specified error.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        /// <param name="P_Args">The Args.</param>
        public void ErrorFormat(string P_Message, params object[] P_Args)
        {
            _Logger.ErrorFormat(CultureInfo.InvariantCulture, P_Message, P_Args);
        }

        public void ErrorFormat(string P_Message, Exception P_Exception, params object[] P_Args)
        {
            _Logger.Error(string.Format(CultureInfo.InvariantCulture, P_Message, P_Args), P_Exception);
        }

        /// <summary>
        /// Logs the specified fatal error.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        public void Fatal(string P_Message)
        {
            _Logger.Fatal(P_Message);
        }

        /// <summary>
        /// Logs the specified fatal error.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        /// <param name="P_Exception">The Exception.</param>
        public void Fatal(string P_Message, Exception P_Exception)
        {
            _Logger.Fatal(P_Message, P_Exception);
        }

        /// <summary>
        /// Logs the specified fatal error.
        /// </summary>
        /// <param name="P_Message">The Message.</param>
        /// <param name="P_Args">The Args.</param>
        public void FatalFormat(string P_Message, params object[] P_Args)
        {
            _Logger.FatalFormat(CultureInfo.InvariantCulture, P_Message, P_Args);
        }

        public void FatalFormat(string P_Message, Exception P_Exception, params object[] P_Args)
        {
            _Logger.Fatal(string.Format(CultureInfo.InvariantCulture, P_Message, P_Args), P_Exception);
        }
    }
}
